


import $ from 'zepto-webpack'


let timer = ""
export default (text,duration=2000)=>{

    const toast = $(".toast")
    const toastContent = $(".toast .toast_content")

    toastContent.text(text)
    toast.show()

    // console.log("toastContent",toastContent)

    timer && clearTimeout(timer)

    timer= setTimeout(() => {
        toast.hide()
    }, duration);

    return {
        close:()=>{
            toast.hide()
            clearTimeout(timer)
        }
    }
}